package com.zjlanyun.eplus.view;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.blankj.utilcode.utils.KeyboardUtils;
import com.zjlanyun.eplus.R;
import com.zjlanyun.eplus.nohttp.CallServer;

import butterknife.ButterKnife;

/**
 * Created by lanyun on 16/5/12.
 * 基础Activity类
 */
public class BaseActivity extends Activity {

    public TextView title;
    public ImageButton ib_back;

    public Context mContext = this;
    public Activity mActivity = this;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    /**
     * 基础初始化，继承后必须调用
     */
    public void initBaseView() {
        ButterKnife.bind(this);
        title = (TextView) findViewById(R.id.title);
        ib_back = (ImageButton) findViewById(R.id.ib_back);

        //后退
        ib_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                KeyboardUtils.hideSoftInput(mActivity);
                finish();
            }
        });
    }

    @Override
    protected void onDestroy() {
        CallServer.getRequestInstance().cancelBySign(mContext);
        super.onDestroy();
        ButterKnife.unbind(this);
    }
}
